package com.fu.plugin.component;

import com.fu.plugin.listeners.PfcDocumentListener;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.event.DocumentListener;
import com.intellij.openapi.editor.event.EditorEventListener;
import com.intellij.openapi.editor.event.EditorEventMulticaster;
import org.jetbrains.annotations.NotNull;

public class PlantUmlApplicationComponent implements ApplicationComponent {

    private DocumentListener plantUmlDocumentListener = new PfcDocumentListener();

    public PlantUmlApplicationComponent()
    {
        PlantUmlApplicationComponent.class.getClassLoader().setDefaultAssertionStatus(false);
    }

    @Override
    public void initComponent(){
        EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster();
        eventMulticaster.addDocumentListener(plantUmlDocumentListener);
    }

    @Override
    public void disposeComponent(){
        EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster();
        eventMulticaster.removeDocumentListener(plantUmlDocumentListener);
    }

    @Override
    @NotNull
    public String getComponentName(){
        return "PlantUmlApplicationComponent";
    }
}
